import { createRouter, createWebHistory } from 'vue-router'
import Login from './components/Login.vue'
import AdminLayout from './components/admin/AdminLayout.vue'
import AdminDashboard from './components/admin/AdminDashboard.vue'
import ActivityManagement from './components/admin/ActivityManagement.vue'  // 导入活动管理组件
import AdminVolunteers from './components/admin/AdminVolunteers.vue'

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  // 管理员路由
  {
    path: '/admin',
    name: 'AdminLayout',
    component: AdminLayout,
    children: [
      {
        path: '',  // 默认子路由
        redirect: 'dashboard'
      },
      {
        path: 'dashboard',
        name: 'AdminDashboard',
        component: AdminDashboard
      },
      {
        path: 'activity-management',
        component: ActivityManagement
      },
      {
        path: 'volunteers',
        component: AdminVolunteers
      }
    ]
  },
  // 志愿者路由
  {
    path: '/volunteer',
    name: 'VolunteerLayout',
    component: () => import('./components/volunteer/VolunteerLayout.vue'),
    children: [
      {
        path: '',  // 默认子路由
        redirect: 'dashboard'
      },
      {
        path: 'dashboard',
        name: 'VolunteerDashboard',
        component: () => import('./components/volunteer/VolunteerDashboard.vue')
      },
      {
        path: 'activities',
        name: 'Activities',
        component: () => import('./components/volunteer/Activities.vue')
      },
      {
        path: 'my-activities',
        name: 'MyActivities',
        component: () => import('./components/volunteer/MyActivities.vue')
      },
      {
        path: 'led-activities',
        name: 'LedActivities',
        component: () => import('./components/volunteer/LedActivities.vue')
      },
      {
        path: 'profile',
        name: 'VolunteerProfile',
        component: () => import('./components/volunteer/VolunteerProfile.vue')
      },
      {
        path: 'attendance/:activityId',
        name: 'Attendance',
        component: () => import('./components/volunteer/Attendance.vue')
      },
      {
        path: 'assessment/:activityId',
        name: 'Assessment',
        component: () => import('./components/volunteer/Assessment.vue')
      }
    ]
  },
  // 404路由
  {
    path: '/:pathMatch(.*)*',
    redirect: '/login'
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router 